import 'package:flutter/material.dart';
import 'package:order/constant/app_colors.dart';
import 'package:order/generated/assets.dart';

class CategoryItem extends StatelessWidget {
  final GestureTapCallback? onTap;
  final dynamic data;
  final bool selected;

  const CategoryItem(
      {super.key, this.onTap, this.data, required this.selected});

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
        onTap: onTap,
        child: AnimatedContainer(
          width: 180,
          height: 60,
          duration: const Duration(milliseconds: 300),
          curve: Curves.fastOutSlowIn,
          margin: const EdgeInsets.only(left: 20, right: 20, top: 20),
          decoration: BoxDecoration(
              borderRadius: const BorderRadius.all(Radius.circular(5)),
              color: selected ? AppColors.bgRed : AppColors.bgWhite,
              boxShadow: [
                BoxShadow(
                    color: Colors.black87.withOpacity(0.1),
                    spreadRadius: 0.5,
                    blurRadius: 0.5,
                    offset: const Offset(0, 1))
              ]),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              Image.asset(selected?data["img2"]:data["img1"], height: 20, width: 20),
              const SizedBox(width: 20,),
              Text(
                data["name"],
                style: TextStyle(
                    fontSize: 20,
                    color:
                    selected ? AppColors.fontWhite : AppColors.fontGrey5),
              )
            ],
          )
        ));
  }
}
